﻿#include<iostream>
#include<map>
#include<set>

int main() {
	std::cout << "std::set" << std::endl;

	std::set<int> mySet;
	//插入
	mySet.insert(3);
	mySet.insert(1);
	mySet.insert(4);
	//遍历
	for (int val : mySet) {
		std::cout << val << std::endl;
	}
	//查找，时间复杂度O(logn)
	auto it = mySet.find(1);
	if (it != mySet.end()) {
		std::cout << "find" << std::endl;
	}
	//删除
	mySet.erase(1);
	

	std::cout << "std::map" << std::endl;

	std::map<std::string, int> myMap;
	//插入
	myMap.insert({ "Alice",90 });
	myMap.emplace("Bob",80);
	myMap["Sunny"] = 70;

	//遍历
	for (auto& kv : myMap) {
		std::cout << "key:" << kv.first << ",value:" << kv.second << std::endl;
	}
	//查找
	auto score = myMap.find("Bob");
	if (score != myMap.end()) {
		std::cout << "Bob's score" << score->second << std::endl;
	}
	
}